<?php

use Doraemon\model\Push as mPush;

class IosPushSettingAction extends ActionPlugin
{

    const USER_LEVEL = self::LEVEL_REGISTER;

    const PUSH_ALLOW = 1; //允许推送
    const PUSH_BAN = 9; //禁止推送


    public function main()
    {
        $allowPush = self::PUSH_BAN;

        $pushInfo = mPush::getOneByDid($this->uid, $this->did);

        if (!$pushInfo) {
            $pushInfo = mPush::getOneByUid($this->uid);
        }
        if ($pushInfo && !empty($pushInfo['device_token'])) {
            $allowPush = $pushInfo['ban_push'] == self::PUSH_ALLOW ? self::PUSH_ALLOW : self::PUSH_BAN;
        }
        $this->setSuccess($allowPush);

    }
}